package com.xuecheng.content.api.controller;


import com.xuecheng.content.model.dto.AddCourseTeacherDto;
import com.xuecheng.content.model.dto.EditCourseTeacherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author Mr.M
 * @version 1.0
 * @description 课程教师信息接口
 * @date 2024/12/15 11:06
 */
@Slf4j
@Api(value = "课程教师信息接口", tags = "课程教师信息接口")
@RestController
public class CourseTeacherController {
    @Autowired
    private CourseTeacherService courseTeacherService;

    @ApiOperation("课程教师查询接口")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> list(@PathVariable Long courseId) {
        List<CourseTeacher> courseTeacherPageResult = courseTeacherService.queryCourseTeacherList(courseId);
        log.info("查询课程列表，参数：{}，结果：{}", courseId, courseTeacherPageResult);
        return courseTeacherPageResult;
    }


    @ApiOperation("新增课程老师信息")
    @PostMapping("/courseTeacher")
    public Integer createBaseInfoDto(@RequestBody AddCourseTeacherDto addCourseTeacherDto) {
        log.info("新增课程老师信息，参数：{}", addCourseTeacherDto);
        return courseTeacherService.createCourseBase(addCourseTeacherDto);
    }


    @ApiOperation("修改课程老师信息")
    @PutMapping("/courseTeacher")
    public Integer modifyCourseBase(@RequestBody @Validated EditCourseTeacherDto editCourseDto) {
        return courseTeacherService.updateCourseBase(editCourseDto);
    }

    @ApiOperation("删除课程老师信息")
    @GetMapping("/course/{id}/{courseId}")
    public Integer getCourseBaseInfo(@PathVariable Long id, @PathVariable Long courseId) {
        log.info("修改课程老师信息，教师id：{}，课程id：{}", id, courseId);
        return courseTeacherService.deleteCourseTeacher(id, courseId);
    }


}
